package com.qfedu.user.controller;

import com.qfedu.common.core.annotation.NoLogin;
import com.qfedu.common.core.common.R;
import com.qfedu.user.service.UserService;
import com.qfedu.user.vo.MyVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 以梦为马，以汗为泉，不忘初心，不负韶华
 *
 * @author
 * @version 1.0
 * @data 2025/6/3 15:35
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 获取当前用户信息
     * @return
     */
    @GetMapping  ("/my")
    public R my(){
        MyVO my = userService.my();
        return R.ok(my);
    }

    /**
     *
     * 获取用户邀请信息
     * @param uid
     * @return
     */
    @NoLogin
    @GetMapping("/invite")
    public R invite(Integer uid) {

        Map<String, Object> invite = userService.invite(uid);
        return R.ok(invite);
    }

    @NoLogin
    @PostMapping("/avatar/upload")
    public R upload(MultipartFile file) {
        String url = userService.uploadAvatar(file);
        return R.ok(url);
    }
}
